package xixirupan.tmgp.tencent.com.vmeim.ui.beautyshop.presenter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.List;

import xixirupan.tmgp.tencent.com.vmeim.R;
import xixirupan.tmgp.tencent.com.vmeim.ui.beautyshop.model.ProductsBaen;

/**
 * Created by lenovo on 2016/10/20.
 */

public class Item5RecyAdapter  extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    List<ProductsBaen>  listBaens; Context context; LayoutInflater inflater;
   public Item5RecyAdapter(List<ProductsBaen>   listBaens, Context context, LayoutInflater inflater)
   {
       this.inflater=inflater;
       this.context =context;
       this.listBaens =listBaens;

   }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.item5_inner_recycler, parent, false);
        InnnerViewHolder holder =new InnnerViewHolder(view);

        return holder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof InnnerViewHolder)
{
    ((InnnerViewHolder) holder).textView_title.setText(listBaens.get(position).getName());
    String sellPrice = listBaens.get(position).getSellPrice();
    ((InnnerViewHolder) holder).price.setText("¥"+sellPrice);
    Glide.with(context).load(listBaens.get(position).getCover()).into(((InnnerViewHolder) holder).imageView);
}
    }

    @Override
    public int getItemCount() {
        return listBaens.size();
    }
    class InnnerViewHolder extends RecyclerView.ViewHolder
    {
        ImageView imageView;
        TextView textView_title;
        TextView price;
        public InnnerViewHolder(View itemView) {
            super(itemView);
            price = (TextView) itemView.findViewById(R.id.price_inner_item5);
            textView_title = (TextView) itemView.findViewById(R.id.title_item5_inner);
            imageView = (ImageView) itemView.findViewById(R.id.inner_item5_img);
        }
    }
}
